package listbyorder.access001_100.test62;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/3 10:35
 */
public class Solution3 {

    // 动态规划空间优化
    public int uniquePaths(int m, int n) {
        int[] dp = new int[n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (j == 0) {
                    dp[j] = 1;
                } else {
                    dp[j] = dp[j] + dp[j - 1];
                }
            }
        }
        return dp[n - 1];
    }
}
